<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>后台显示</title>
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="/three/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="/three/static/h-ui.admin/css/style.css" />
<script type="text/javascript"
	src="/three/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/three/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/three/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript"
	src="/three/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript"
	src="/three/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript"
	src="/three/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/three/lib/laypage/1.2/laypage.js"></script>
</head>
<body>
	<form action="" method="post" id="queryForm">
		<div class="page-container">
			<!-- 开始 模糊查询 -->
			<div>
				<table class="table">
					<tr>
						<td>订单编号:<input type="text" class="input-text"
							style="width: 200px" name="orderId">
						</td>
						<td>顾客账号:<input type="text" class="input-text"
							style="width: 200px" name="phone"></td>
						<td>顾客姓名:<input type="text" class="input-text"
							style="width: 200px" name="shopname"></td>
						<td>消费内容:<input type="text" class="input-text"
							style="width: 200px" name="project"></td>
					</tr>
					<tr>
						<td>服务员工:<input type="text" class="input-text"
							style="width: 200px" name="username"></td>
						<td>操作员工:<input type="text" class="input-text"
							style="width: 200px" name="shopusername"></td>
						<td>完成日期: <input type="text"
							onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}'})"
							id="datemin" name="qstartTime" value="${qstartTime}"
							class="input-text Wdate" style="width: 100px;"> 至 <input
							type="text"
							onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d'})"
							id="datemax" name="qendTime" value="${qendTime}"
							class="input-text Wdate" style="width: 100px;"></td>
						<td align="center"><button type="submit" class="btn btn-success" value="查询">
								<i class="Hui-iconfont">&#xe665;</i> 查询
							</button></td>
					</tr>
					<tr>
						<td>订单状态:<span class="select-box" style="width: 150px">
								<select class="select" name="orderStatus" size="1">
									<option value="">请选择订单状态</option>
									<option value="1">草稿</option>
									<option value="2">已预约</option>
									<option value="3">服务中</option>
									<option value="4">待支付</option>
									<option value="5">已支付</option>
									<option value="6">已完成</option>
									<option value="7">已过期</option>
									<option value="8">已撤销</option>
							</select>
						</span></td>
						<td>支付方式:<span class="select-box" style="width: 150px">
								<select class="select" name="payWay" size="1">
									<option value="">请选择支付方式</option>
									<option value="1">微信</option>
									<option value="2">支付宝</option>
									<option value="3">美颜币</option>
									<option value="4">套餐</option>
							</select>
						</span></td>
						<td>店铺名称:<span class="select-box" style="width: 150px">
								<select class="select" name="shopName" size="1">
									<option value="">请选择店铺名称</option>
									<c:forEach items="${shops}" var="shop">
										<option value="${shop.shopId }">${shop.shopName }</option>
									</c:forEach>
							</select>
						</span></td>
						<td>订单来源:<span class="select-box" style="width: 150px">
								<select class="select" name="orderSource" size="1">
									<option value="">请选择订单来源</option>
									<option value="1">平台</option>
									<option value="2">商家</option>
							</select>
						</span></td>
					</tr>
				</table>
			</div>
			<!-- 结束 模糊查询 -->

			<!-- 开始数据导出为excel -->
			<button type="button" class="btn btn-success" value="导出Excel"
				onclick="method5('tableExcel')">
				<i class="Hui-iconfont">&#xe665;</i>导出Excel
			</button>
			<script language="JavaScript" type="text/javascript">
				var idTmr;
				function getExplorer() {
					var explorer = window.navigator.userAgent;
					//ie  
					if (explorer.indexOf("MSIE") >= 0) {
						return 'ie';
					}
					//firefox  
					else if (explorer.indexOf("Firefox") >= 0) {
						return 'Firefox';
					}
					//Chrome  
					else if (explorer.indexOf("Chrome") >= 0) {
						return 'Chrome';
					}
					//Opera  
					else if (explorer.indexOf("Opera") >= 0) {
						return 'Opera';
					}
					//Safari  
					else if (explorer.indexOf("Safari") >= 0) {
						return 'Safari';
					}
				}
				function method5(tableid) {
					if (getExplorer() == 'ie') {
						var curTbl = document.getElementById(tableid);
						var oXL = new ActiveXObject("Excel.Application");
						var oWB = oXL.Workbooks.Add();
						var xlsheet = oWB.Worksheets(1);
						var sel = document.body.createTextRange();
						sel.moveToElementText(curTbl);
						sel.select();
						sel.execCommand("Copy");
						xlsheet.Paste();
						oXL.Visible = true;

						try {
							var fname = oXL.Application.GetSaveAsFilename(
									"Excel.xls",
									"Excel Spreadsheets (*.xls), *.xls");
						} catch (e) {
							print("Nested catch caught " + e);
						} finally {
							oWB.SaveAs(fname);
							oWB.Close(savechanges = false);
							oXL.Quit();
							oXL = null;
							idTmr = window.setInterval("Cleanup();", 1);
						}

					} else {
						tableToExcel(tableid)
					}
				}
				function Cleanup() {
					window.clearInterval(idTmr);
					CollectGarbage();
				}
				var tableToExcel = (function() {
					var uri = 'data:application/vnd.ms-excel;base64,', template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>', base64 = function(
							s) {
						return window.btoa(unescape(encodeURIComponent(s)))
					}, format = function(s, c) {
						return s.replace(/{(\w+)}/g, function(m, p) {
							return c[p];
						})
					}
					return function(table, name) {
						if (!table.nodeType)
							table = document.getElementById(table)
						var ctx = {
							worksheet : name || 'Worksheet',
							table : table.innerHTML
						}
						window.location.href = uri
								+ base64(format(template, ctx))
					}
				})()
			</script>
			<!-- 结束数据导出为excel -->

			<!-- 开始 数据显示 -->
			<div class="mt-20">
				<table
					class="table table-border table-bordered table-bg table-hover table-sort table-responsive"
					id="tableExcel">
					<thead>
						<tr class="text-c">
							<td width="80">订单编号</td>
							<td>顾客账号</td>
							<td>顾客姓名</td>
							<td>消费内容</td>
							<td>价格(元)</td>
							<td>支付方式</td>
							<td>实付金额(元)</td>
							<td>消耗颜值</td>
							<td>店铺编号</td>
							<td>店铺名称</td>
							<td>服务员工</td>
							<td>最后操作员工</td>
							<td>支付时间</td>
							<td>完成时间</td>
							<td>状态</td>
							<td>订单来源</td>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${list}" var="bus">
							<tr class="text-c">
								<td>${bus.orderId }</td>
								<td>${bus.bisCustomUser.mobile }</td>
								<td>${bus.bisCustomUser.username}</td>
								<td>${bus.bisNurseProject.projectName}</td>
								<td><c:if test="${bus.orderMoney==null}">
										<span>0.00</span>
									</c:if> <c:if test="${bus.orderMoney!=null}">
										<span>${bus.orderMoney}</span>
									</c:if></td>
								<td><c:if test="${bus.payWay=='1'}">
					  微信
					 </c:if> <c:if test="${bus.payWay=='2'}">
					  支付宝
					 </c:if> <c:if test="${bus.payWay=='3'}">
					  美颜币
					 </c:if> <c:if test="${bus.payWay=='4'}">
					  套餐
					 </c:if></td>
								<td><c:if test="${bus.payMoney==null}">
										<span>0.00</span>
									</c:if> <c:if test="${bus.payMoney!=null}">
										<span>${bus.payMoney}</span>
									</c:if></td>
								<td><c:if test="${bus.extendBeautyNum==null}">
										<span>0.00</span>
									</c:if> <c:if test="${bus.extendBeautyNum!=null}">
										<span>${bus.extendBeautyNum}</span>
									</c:if></td>
								<td>${bus.bisShop.shopId}</td>
								<td>${bus.bisShop.shopName}</td>
								<td>${bus.bisShopUser.username}</td>
								<td>${bus.bisShopUser.username}</td>
								<td><f:formatDate value="${bus.payTime}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td><f:formatDate value="${bus.finishTime}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td><c:if test="${bus.orderStatus==1}">
					  草稿
					 </c:if> <c:if test="${bus.orderStatus==2}">
					  已预约
					 </c:if> <c:if test="${bus.orderStatus==3}">
					  服务中
					 </c:if> <c:if test="${bus.orderStatus==4}">
					  待支付
					 </c:if> <c:if test="${bus.orderStatus==5}">
					  已支付
					 </c:if> <c:if test="${bus.orderStatus==6}">
					  已完成
					 </c:if> <c:if test="${bus.orderStatus==7}">
					  已过期
					 </c:if> <c:if test="${bus.orderStatus==8}">
					  已撤销
					 </c:if></td>
								<td><c:if test="${bus.orderSource==1}">
					  平台
					 </c:if> <c:if test="${bus.orderSource==2}">
					  商家
					 </c:if></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<!-- 结束 数据显示 -->
		</div>
	</form>
</body>
<script type="text/javascript">
	/*护理项目-排序*/
	$('.table-sort').dataTable({
		"aaSorting" : [ [ 1, "desc" ] ],//默认第几个排序
		"bStateSave" : true,//状态保存
	/* "pading":false,
	"aoColumnDefs": [
	  {"orderable":false,"aTargets":[0,8]}// 不参与排序的列
	] */
	});
</script>
</html>